﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

using System.Numerics;

namespace Xuhengxiao.Math
{
    public partial class frmArithmeticExpression : Form
    {
        public frmArithmeticExpression()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ArithmeticExpression a = new ArithmeticExpression();

            textBox2.Text = a.Eval(textBox1.Text);

            textBox2.Text += "  ANS=" + ArithmeticExpression.getVarAndConst("ANS");

            

        }

        private void button2_Click(object sender, EventArgs e)
        {
            double dbl = Convert.ToDouble("1.085e-2");
            MessageBox.Show(dbl.ToString());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            ArithmeticExpression a = new ArithmeticExpression();
            Stack stack = a.ConvertExprBack(textBox1.Text);

            
            while (stack.Count>0)
            {
                textBox3.Text += ((ClsPhrase ) stack.Pop()).ToString()+Environment.NewLine;
                
            }

        }

        private void button4_Click(object sender, EventArgs e)
        {
            ArithmeticExpression a = new ArithmeticExpression();
            Stack stack = a.ConvertExprBack(textBox1.Text);
            Complex c = a.Calc_ExprBack(stack);
            textBox4.Text = c.ToString();

        }

        private void button5_Click(object sender, EventArgs e)
        {
            //经检测,双曲函数不分角度弧度
            textBox5.Text = System.Math.Sinh(5).ToString() + Environment.NewLine + Complex.Sinh(new Complex(5, 0)).ToString() + Environment.NewLine;

            textBox5.Text += Complex.Sin(new Complex(30,0) * System.Math.PI / 180);
        }
    }
}
